package com.ruoyi.web.controller.picture;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.weixin.entity.Tab;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.picture.domain.Actab;
import com.ruoyi.picture.service.IActabService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * actabController
 * 
 * @author ruoyi
 * @date 2024-01-15
 */
@RestController
@RequestMapping("/picture/tab")
public class ActabController extends BaseController
{
    @Autowired
    private IActabService actabService;

    /**
     * 查询actab列表
     */
    @PreAuthorize("@ss.hasPermi('picture:tab:list')")
    @GetMapping("/list")
    public TableDataInfo list(Actab actab)
    {
        startPage();
        List<Actab> list = actabService.selectActabList(actab);
        return getDataTable(list);
    }


    @GetMapping("/listTotast")
    public TableDataInfo listTotast(Long id)
    {
        List<Actab> list = actabService.listTotast(id);
        return getDataTable(list);
    }
    /**
     * 导出actab列表
     */
    @PreAuthorize("@ss.hasPermi('picture:tab:export')")
    @Log(title = "actab", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Actab actab)
    {
        List<Actab> list = actabService.selectActabList(actab);
        ExcelUtil<Actab> util = new ExcelUtil<Actab>(Actab.class);
        util.exportExcel(response, list, "actab数据");
    }

    /**
     * 获取actab详细信息
     */
    @PreAuthorize("@ss.hasPermi('picture:tab:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(actabService.selectActabById(id));
    }

    /**
     * 新增actab
     */
    @PreAuthorize("@ss.hasPermi('picture:tab:add')")
    @Log(title = "actab", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Actab actab)
    {
        return toAjax(actabService.insertActab(actab));
    }

    /**
     * 修改actab
     */
    @PreAuthorize("@ss.hasPermi('picture:tab:edit')")
    @Log(title = "actab", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Actab actab)
    {
        return toAjax(actabService.updateActab(actab));
    }

    /**
     * 删除actab
     */
    @PreAuthorize("@ss.hasPermi('picture:tab:remove')")
    @Log(title = "actab", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(actabService.deleteActabByIds(ids));
    }
}
